//
//  CustomButton.m
//  WashForU
//
//  Created by 王俊 on 15/11/28.
//  Copyright © 2015年 王俊. All rights reserved.
//

#import "CustomButton.h"

@implementation CustomButton


- (instancetype)initWithImageAndLabel:(NSString *)imageName highLightedImageName:(NSString*)highlightedImageName labelText:(NSString *)labelText
{
    if (self = [super init]) {
        
    self.buttonImage     = [[UIButton alloc]init];
    UILabel      *label           = [[UILabel alloc]init];
    
    [self.buttonImage setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [self.buttonImage setImage:[UIImage imageNamed:highlightedImageName] forState:UIControlStateHighlighted];
    
    label.text               = labelText;
    label.textAlignment      = NSTextAlignmentCenter;
    label.textColor          = [UIColor GrayColor_88];
    label.font               = [UIFont CustomFont:16];
    
    
    [self  addSubview:self.buttonImage];
    [self addSubview:label];
    
    [self.buttonImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.height.width.equalTo(self.mas_width).multipliedBy(19.0/20);
        make.top.equalTo(self).offset(5);
    }];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.width.equalTo(self.buttonImage);
        make.height.equalTo(self.mas_width).multipliedBy(45.0/200.0);
        make.top.equalTo(self.buttonImage.mas_bottom).offset(5);
    }];
    }
    return self ;
}


@end
